package org.steven0lisa.typhoon.ui;

import org.steven0lisa.typhoon.R;
import org.steven0lisa.typhoon.bean.Typhoon;
import org.steven0lisa.typhoon.bean.TyphoonStatus;
import org.steven0lisa.typhoon.models.TyphoonModel;

import android.content.Context;
import android.widget.Toast;

import com.baidu.mapapi.map.OverlayItem;
import com.baidu.platform.comapi.basestruct.GeoPoint;

public class TyphoonLocationOverlayItem extends OverlayItem {
	
	TyphoonStatus status;
	Context context;
	String typhoonType;
	TyphoonWindOverlay windOverlay;

	public TyphoonLocationOverlayItem(Context context, GeoPoint point, TyphoonStatus status, TyphoonWindOverlay windOverlay) {
		super(point, "", "");
		this.status = status;
		this.context=context;
		this.windOverlay=windOverlay;
		
		int speed = Integer.parseInt(status.current.spe);
		if(speed >= 51){
			setMarker(context.getResources().getDrawable(R.drawable.strong_superty));
			typhoonType = "超强台风";
		}else if(speed >= 41){
			setMarker(context.getResources().getDrawable(R.drawable.strong_sty));
			typhoonType = "强台风";
		}else if(speed >= 32){
			setMarker(context.getResources().getDrawable(R.drawable.strong_ty));
			typhoonType = "台风";
		}else if(speed >= 24){
			setMarker(context.getResources().getDrawable(R.drawable.strong_sts));
			typhoonType = "强热带风暴";
		}else if(speed >= 17){
			setMarker(context.getResources().getDrawable(R.drawable.strong_ts));
			typhoonType = "热带风暴";
		}else{
			setMarker(context.getResources().getDrawable(R.drawable.strong_td));
			typhoonType = "热带低压";
		}
	}
	
	public void onTap(){
		Typhoon typhoon = TyphoonModel.findTyhoonById(status.typhoon_id);
		windOverlay.toggleDisplayStatus(status);
		Toast.makeText(context, String.format("%s，%s\n风速：%sm/s\n时间：%s",typhoon.cn_name, typhoonType, status.current.spe, status.current_time), Toast.LENGTH_SHORT).show();
	}
	
	

}
